import { sendAndConfirmTransaction as realSendAndConfirmTransaction } from '@solana/web3.js'
import type { Account, Connection, Transaction, TransactionSignature } from '@solana/web3.js'
import { WalletAdapter } from '@/wallets'

export function sendAndConfirmTransaction(
  title: string,
  connection: Connection,
  transaction: Transaction,
  ...signers: Array<Account>
): Promise<TransactionSignature> {
  return realSendAndConfirmTransaction(connection, transaction, signers, {
    skipPreflight: false,
    commitment: 'recent',
    preflightCommitment: 'recent'
  })
}

export async function sendTransaction(
  connection: Connection,
  wallet: WalletAdapter,
  transaction: Transaction,
  signers: Array<Account>
) {
  return await wallet.signTransaction(transaction)
}
